package com.macro.controller;


import com.macro.pojos.dto.ResponseResult;
import com.macro.pojos.dto.RoleDto;
import com.macro.pojos.pojo.Role;
import com.macro.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/api/v1/role")
@Api(tags = "角色相关接口")
public class RoleController {
    @Autowired
    private RoleService roleService;

    /**
     * 查询所有角色
     * @return
     */
    @GetMapping("find_all_role")
    @ApiOperation(value = "查询所有角色")
    public List<Role> findAllRole(){
        return roleService.findAllRole();
    }

    /**
     * 添加角色
     * @return
     */
    @GetMapping("add_role")
    @ApiOperation(value = "添加角色")
    public ResponseResult AddRole(@RequestBody RoleDto roleDto){
        return roleService.AddRole(roleDto);
    }

    /**
     * 修改角色
     * @return
     */
    @GetMapping("update_role_dto")
    @ApiOperation(value = "修改角色")
    public ResponseResult updateRoleDto(@RequestBody RoleDto roleDto){
        return roleService.updateRoleDto(roleDto);
    }

    /**
     * 删除角色
     * @return
     */
    @GetMapping("del_role")
    @ApiOperation(value = "删除角色")
    public ResponseResult delRole(@RequestParam Integer  id){
        return roleService.delRole(id);
    }

}
